package com.yss.reportworld.service.impl;

import java.util.*;
import java.util.stream.Collectors;

import com.alibaba.excel.ExcelReader;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yss.common.core.constant.RequestDataHelper;
import com.yss.common.core.domain.TreeNode;
import com.yss.common.core.enums.YssStatusEnum;
import com.yss.common.core.enums.YssYseNoEnum;
import com.yss.common.core.exception.BusinessException;
import com.yss.common.core.utils.file.FileUtils;
import com.yss.common.core.utils.uuid.IdUtils;
import com.yss.common.security.utils.DictUtils;
import com.yss.reportworld.domain.dim.*;
import com.yss.reportworld.enums.ReportWorldEnum;
import com.yss.reportworld.mapper.dim.*;
import com.yss.reportworld.util.TableInfoUtil;
import com.yss.system.api.domain.SysDictData;
import lombok.extern.slf4j.Slf4j;
import com.yss.common.core.utils.StringUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yss.reportworld.service.IDimZblxService;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

/**
 * 指标类型Service业务层处理
 *
 * @author yss
 * @date 2023-05-12
 */
@Slf4j
@Service
public class DimZblxServiceImpl extends ServiceImpl<DimZblxMapper, DimZblx> implements IDimZblxService {

    @Autowired
    private DimValuatInfoMapper dimValuatInfoMapper;
    @Autowired
    private DimInfoInfoMapper dimInfoInfoMapper;
    @Autowired
    private DimNoStInfoMapper dimNoStInfoMapper;
    @Autowired
    private DimTxInfoMapper dimTxInfoMapper;
    @Autowired
    private DimPdInfoMapper dimPdInfoMapper;
    @Autowired
    private DimTaInfoMapper dimTaInfoMapper;

    /**
     * 查询指标类型列表
     *
     * @param dimZblx 指标类型
     * @return 指标类型
     */
    @Override
    public List<DimZblx> selectDimZblxList(DimZblx dimZblx) {
        QueryWrapper<DimZblx> wrapper = new QueryWrapper();
        wrapper.orderByAsc("ORDER_NUM");
        if (StringUtils.isNotEmpty(dimZblx.getZblxType())) {
            wrapper.eq("ZBLX_TYPE", dimZblx.getZblxType());
        }
        if (null != dimZblx.getStatus()) {
            wrapper.eq("STATUS", dimZblx.getStatus());
        }
        return this.list(wrapper);
    }

    /**
     * 校验编码是否唯一
     *
     * @param dimZblx
     * @return 结果
     */
    @Override
    public boolean checkDimZblxCodeeUnique(DimZblx dimZblx) {
        String zblxId = StringUtils.isNull(dimZblx.getId()) ? "-1" : dimZblx.getId();
        QueryWrapper<DimZblx> wrapper = new QueryWrapper<>();
        wrapper.eq("FINDX_TP_CODE", dimZblx.getFindxTpCode());
        DimZblx info = this.getOne(wrapper);
        if (StringUtils.isNotNull(info) && !info.getId().equals(zblxId)) {
            return false;
        }
        return true;
    }

    /**
     * 删除指标信息表
     *
     * @param id
     */
    @Transactional
    public void removeDimZblx(String id) {
        DimZblx dimZblx = this.getById(id);
       /* if (StringUtils.isNotNull(dimZblx) && StringUtils.isNotEmpty(dimZblx.getZblxType())) {
            // 核算
            QueryWrapper<DimHswd> wrapperHswd = new QueryWrapper<>();
            wrapperHswd.eq("FINDX_TP_CODE", dimZblx.getFindxTpCode());
            dimHswdMapper.delete(wrapperHswd);
            // 资讯
            QueryWrapper<DimZxwd> wrapperZxwd = new QueryWrapper<>();
            wrapperZxwd.eq("FINDX_TP_CODE", dimZblx.getFindxTpCode());
            dimZxwdMapper.delete(wrapperZxwd);
            //交易
            QueryWrapper<DimJywd> wrapperJywd = new QueryWrapper<>();
            wrapperJywd.eq("FINDX_TP_CODE", dimZblx.getFindxTpCode());
            dimJywdMapper.delete(wrapperJywd);
            // 非标
            QueryWrapper<DimFbwd> wrapperFbwd = new QueryWrapper<>();
            wrapperFbwd.eq("FINDX_TP_CODE", dimZblx.getFindxTpCode());
            dimFbwdMapper.delete(wrapperFbwd);
            // 特殊
            QueryWrapper<DimTswd> wrapperTswd = new QueryWrapper<>();
            wrapperTswd.eq("FINDX_TP_CODE", dimZblx.getFindxTpCode());
            dimTswdMapper.delete(wrapperTswd);
        }*/
        this.removeById(id);
    }


    /**
     * 查询指标类型树结构信息
     *
     * @return 指标类型树信息集合
     */
    public List<TreeNode> selectDimZblxTreeList() {
        List<TreeNode> list = new ArrayList<>();
        QueryWrapper<DimZblx> wrapper = new QueryWrapper<>();
        wrapper.orderByAsc("PARENT_ID,ORDER_NUM");
        wrapper.eq("STATUS", YssStatusEnum.NORMAL.getCode());
        List<DimZblx> listZblxes = this.list(wrapper);
        if (StringUtils.isEmpty(listZblxes)) {
            return list;
        }
        List<String> tempList = listZblxes.stream().map(DimZblx::getId).collect(Collectors.toList());
        Set<String> set = new HashSet<>();
        for (DimZblx zblx : listZblxes) {
            if (set.contains(zblx.getParentId()) || tempList.contains(zblx.getParentId())) {
                continue;
            }
            list.addAll(this.recursionTree(zblx.getParentId(), listZblxes));
            set.add(zblx.getParentId());
        }
        return list;
    }

    private List<TreeNode> recursionTree(String id, List<DimZblx> listZblxes) {
        List<TreeNode> list = new ArrayList<>();
        for (DimZblx zblx : listZblxes) {
            if (!id.equals(zblx.getParentId())) {
                continue;
            }
            TreeNode treeNode = this.handBbsjZblxToNode(zblx);
            List<TreeNode> children = recursionTree(zblx.getId(), listZblxes);
            treeNode.setChildren(children);
            list.add(treeNode);
        }
        return list;
    }

    /**
     * 将业务功能转化成TreeNode
     */
    private TreeNode handBbsjZblxToNode(DimZblx dimZblx) {
        TreeNode node = new TreeNode();
        node.setId(dimZblx.getFindxTpCode());
        node.setParentId(dimZblx.getParentId());
        node.setLabel(dimZblx.getFindxTpCode() + "_" + dimZblx.getFindxNm());
        return node;
    }

    /**
     * 读取 指标文件信息
     *
     * @param multipartfile
     * @param updateSupport
     * @param hisVersion
     * @return
     */
    public String readDimZblxInfo(MultipartFile multipartfile, boolean updateSupport, String hisVersion) {
        StringBuffer buffer = new StringBuffer();
        try {
            if (null == multipartfile) {
                throw new BusinessException("没有获取到文件，请稍后重试！");
            }
            TableInfoUtil.handleTableVersion(hisVersion); // 替换表名
            // 获取现在最大的版本号
            String version = hisVersion;
            if (StringUtils.isEmpty(hisVersion) || "NULL".equals(hisVersion.toUpperCase())) {
                List<SysDictData> dictDatas = DictUtils.getDictCache(ReportWorldEnum.REPORT_VERSION.getCode());
                if (StringUtils.isEmpty(dictDatas) || StringUtils.isEmpty(dictDatas.get(0).getDictValue())) {
                    throw new BusinessException("没有获取到版本号，请稍后重试！");
                }
                version = dictDatas.get(0).getDictValue();
            }
            // 读取第一个sheet
            List<List<Object>> listData = FileUtils.readerExcelObj(FileUtils.MultipartFileToFile(multipartfile), 0);
            if (StringUtils.isEmpty(listData) || listData.size() == 1) {
                buffer.append("没有获取到文件的内容，请稍后重试！");
            }
            List<DimZblx> list = new ArrayList<>();
            int orderNum = 1, orderNum2 = 1;
            String pId = "0";
            for (int i = 1; i < listData.size(); i++) {
                List<Object> objectList = listData.get(i);
                if (StringUtils.isEmpty(objectList)) {
                    continue;
                }
                DimZblx dimZblx = new DimZblx();
                Object findxTpCode = objectList.get(0); // 指标类型编号
                dimZblx.setFindxTpCode(String.valueOf(findxTpCode));
                Object findxNm = objectList.get(1); // 指标名称
                dimZblx.setFindxNm(String.valueOf(findxNm));
                Object zblxType = objectList.get(2); // 指标类型
                dimZblx.setZblxType(String.valueOf(zblxType));
                Object parentId = objectList.get(3); // 上级指标编码
                if (StringUtils.isNull(parentId) || StringUtils.isEmpty(parentId.toString())) {
                    pId = IdUtils.fastSimpleUUID();
                    dimZblx.setId(pId);
                    dimZblx.setParentId("0");
                    dimZblx.setOrderNum(orderNum);
                    orderNum++;
                    orderNum2 = 1;
                } else {
                    dimZblx.setId(IdUtils.fastSimpleUUID());
                    dimZblx.setParentId(pId);
                    dimZblx.setOrderNum(orderNum2);
                    orderNum2++;
                }
                dimZblx.setStatus(YssYseNoEnum.YES.getCode());
                dimZblx.setVersion(version);
                list.add(dimZblx);
            }
            this.remove(new QueryWrapper<>());
            if (!StringUtils.isEmpty(list)) {
                this.saveBatch(list);
            }
            buffer.append("成功读取指标信息").append("数" + (list.size()) + "条").append("\r\n");
            // 读取第二个sheet
            List<List<Object>> listData2 = FileUtils.readerExcelObj(FileUtils.MultipartFileToFile(multipartfile), 1, 2);
            if (StringUtils.isEmpty(listData2) || listData2.size() == 1) {
                buffer.append("没有获取到文件的内容，请稍后重试！");
            }
            dimValuatInfoMapper.delete(new QueryWrapper<>());
            dimInfoInfoMapper.delete(new QueryWrapper<>());
            dimNoStInfoMapper.delete(new QueryWrapper<>());
            dimTxInfoMapper.delete(new QueryWrapper<>());
            dimPdInfoMapper.delete(new QueryWrapper<>());
            dimTaInfoMapper.delete(new QueryWrapper<>());
            List<DimValuatInfo> listDimValuatInfo = new ArrayList<>();
            List<DimInfoInfo> listDimInfoInfo = new ArrayList<>();
            List<DimTxInfo> listDimTxInfo = new ArrayList<>();
            List<DimNoStInfo> listDimNoStInfo = new ArrayList<>();
            List<DimPdInfo> listDimPdInfo = new ArrayList<>();
            List<DimTaInfo> listDimTaInfo = new ArrayList<>();
            int orderNumInfo = 0;
            String findxTpCode = "000";
            for (int i = 3; i < listData2.size(); i++) {
                List<Object> objectList = listData2.get(i);
                if (StringUtils.isEmpty(objectList)) {
                    continue;
                }
                if (findxTpCode.equals(objectList.get(0).toString())) {
                    orderNumInfo++;
                } else {
                    orderNumInfo = 1;
                }
                int num = 1;
                findxTpCode = objectList.get(0).toString(); // 指标类型编号
                num = this.getDimValuatInfoList(objectList, listDimValuatInfo, orderNumInfo, num); //估值
                num = this.getDimPdInfoList(objectList, listDimPdInfo, orderNumInfo, num); //产品
                num = this.getDimInfoInfoList(objectList, listDimInfoInfo, orderNumInfo, num); // 资讯
                num = this.getDimTxInfoList(objectList, listDimTxInfo, orderNumInfo, num);   // 交易
                num = this.getDimNoStInfoList(objectList, listDimNoStInfo, orderNumInfo, num); //非标
                num = this.getDimTaInfoList(objectList, listDimTaInfo, orderNumInfo, num); //TA
            }
            buffer.append("\r\n成功读取指标维度信息").append("数" + (listDimValuatInfo.size()) + "条").append("\r\n");
            // 读取第三个sheet
            List<List<Object>> listData3 = FileUtils.readerExcelObj(FileUtils.MultipartFileToFile(multipartfile), 2, 2);
            if (StringUtils.isEmpty(listData3) || listData3.size() == 1) {
                buffer.append("没有获取到文件的内容，请稍后重试！");
            }
            int orderNumInfo3 = 0;
            String findxTpCode3 = "000";
            for (int i = 3; i < listData3.size(); i++) {
                List<Object> objectList = listData3.get(i);
                if (StringUtils.isEmpty(objectList)) {
                    continue;
                }
                if (findxTpCode3.equals(objectList.get(0).toString())) {
                    orderNumInfo3++;
                } else {
                    orderNumInfo3 = 1;
                }
                int num = 1;
                findxTpCode3 = objectList.get(0).toString(); // 指标类型编号
                num = this.getDimPdInfoList(objectList, listDimPdInfo, orderNumInfo3, num); //产品
                num = this.getDimTaInfoList(objectList, listDimTaInfo, orderNumInfo3, num); //TA
            }
            if (StringUtils.isNotEmpty(listDimValuatInfo)) {
                for (DimValuatInfo valuatInfo : listDimValuatInfo) {
                    dimValuatInfoMapper.insert(valuatInfo);
                }
            }
            if (StringUtils.isNotEmpty(listDimInfoInfo)) {
                for (DimInfoInfo infoInfo : listDimInfoInfo) {
                    dimInfoInfoMapper.insert(infoInfo);
                }
            }
            if (StringUtils.isNotEmpty(listDimTxInfo)) {
                for (DimTxInfo dimTxInfo : listDimTxInfo) {
                    dimTxInfoMapper.insert(dimTxInfo);
                }
            }
            if (StringUtils.isNotEmpty(listDimNoStInfo)) {
                for (DimNoStInfo dimNoStInfo : listDimNoStInfo) {
                    dimNoStInfoMapper.insert(dimNoStInfo);
                }
            }
            if (StringUtils.isNotEmpty(listDimPdInfo)) {
                for (DimPdInfo dimPdInfo : listDimPdInfo) {
                    dimPdInfoMapper.insert(dimPdInfo);
                }
            }
            if (StringUtils.isNotEmpty(listDimTaInfo)) {
                for (DimTaInfo dimTaInfo : listDimTaInfo) {
                    dimTaInfoMapper.insert(dimTaInfo);
                }
            }
            buffer.append("\r\n成功读取指标维度信息").append("数" + (listDimPdInfo.size()) + "条").append("\r\n");
        } catch (Exception ex) {
            log.error(ex.getMessage());
            throw new BusinessException(ex.getMessage());
        } finally {
            RequestDataHelper.removeThreadLocal();
        }
        return buffer.toString();
    }


    // 估值的指标
    private int getDimValuatInfoList(List<Object> objectList, List<DimValuatInfo> listDimValuatInfo, int orderNumInfo, int num) {
        DimValuatInfo valuatInfo = new DimValuatInfo();
        Object findxTpCode = objectList.get(0); // 指标类型编号
        valuatInfo.setFindxTpCode(findxTpCode.toString());
        // FEXCH_CD 核算 市场代码
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            valuatInfo.setFexchCd(objectList.get(num).toString());
        }
        num++;
        // FCCY_CD 核算 核算 币种
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            valuatInfo.setFccyCd(objectList.get(num).toString());
        }
        num++;
        // FINVEST_CLA_CD 核算 投资分类
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            valuatInfo.setFinvestClaCd(objectList.get(num).toString());
        }
        num++;
        // FSUBJECT_TP_CD  核算 资产类型
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            valuatInfo.setFsubjectTpCd(objectList.get(num).toString());
        }
        num++;
        // FTX_ATTR_CD  核算 交易属性
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            valuatInfo.setFtxAttrCd(objectList.get(num).toString());
        }
        num++;
        // FACCT_CD  核算 核算项目
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            valuatInfo.setFacctCd(objectList.get(num).toString());
        }
        num++;
        // FISSUE_MODE_CD  核算 发行方式
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            valuatInfo.setFissueModeCd(objectList.get(num).toString());
        }
        num++;
        // FRECV_PAY_CD  核算 账户或费用代码
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            valuatInfo.setFrecvPayCd(objectList.get(num).toString());
        }
        num++;
        // FSEC_VARIETIES_CD  核算 证券品种
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            valuatInfo.setFsecVarietiesCd(objectList.get(num).toString());
        }
        num++;
        // FSEC_VARIETIES_DTL_CD  核算 证券明细品种
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            valuatInfo.setFsecVarietiesDtlCd(objectList.get(num).toString());
        }
        num++;
        // FSUBJECT_LVL  核算 科目层级
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            valuatInfo.setFsubjectLvl(objectList.get(num).toString());
        }
        num++;
        // FPOSIT_NEG_DIREC  核算 正负方向
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            valuatInfo.setFpositNegDirec(objectList.get(num).toString());
        }
        num++;
        // FDOM_FGN_FLAG  核算 境内境外
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            valuatInfo.setFdomFgnFlag(objectList.get(num).toString());
        }
        num++;
        // FREMAIN_PERIOD_DT  核算 剩余期限
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            valuatInfo.setFremainPeriodDt(objectList.get(num).toString());
        }
        num++;
        // FNET_MV_BC  核算 市值本币(净市值本位币)
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            valuatInfo.setFnetMvBc(objectList.get(num).toString());
        }
        num++;
        // FNET_COST_BC 核算 成本本币(净成本本位币)
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            valuatInfo.setFnetCostBc(objectList.get(num).toString());
        }
        num++;
        // FIS_CONS_FLOAT 核算 是否受限流通
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            valuatInfo.setFisConsFloat(objectList.get(num).toString());
        }
        num++;
        valuatInfo.setOrderNum(orderNumInfo);
        listDimValuatInfo.add(valuatInfo);
        return num;
    }


    // 产品维度
    private int getDimPdInfoList(List<Object> objectList, List<DimPdInfo> listDimPdInfo, int orderNumInfo, int num) {
        DimPdInfo dimPdInfo = new DimPdInfo();
        Object findxTpCode = objectList.get(0); // 指标类型编号
        dimPdInfo.setFindxTpCode(findxTpCode.toString());
        // FVALUAT_WAY_CD 产品 是否摊余成本法（估值方式）
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            dimPdInfo.setFvaluatWayCd(objectList.get(num).toString());
        }
        num++;
        // FOPER_MODE_CD 产品 运行方式
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            dimPdInfo.setFoperModeCd(objectList.get(num).toString());
        }
        num++;
        // FRAISE_MODE_CD 产品 募集方式
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            dimPdInfo.setFraiseModeCd(objectList.get(num).toString());
        }
        num++;
        // FMAG_MODE_CD  产品 管理方式
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            dimPdInfo.setFmagModeCd(objectList.get(num).toString());
        }
        num++;
        // FTRUSTEE_DUTY_CD  产品 受托职责
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            dimPdInfo.setFtrusteeDutyCd(objectList.get(num).toString());
        }
        num++;
        // FPD_TP  产品 产品类型
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            dimPdInfo.setFpdTp(objectList.get(num).toString());
        }
        num++;
        // FIS_GRADE_PD   产品 分级产品
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            dimPdInfo.setFisGradePd(objectList.get(num).toString());
        }
        num++;
        // FINCOME_RIGHT_TRAN_PD_FLAG  产品 收益权转让产品
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            dimPdInfo.setFincomeRightTranPdFlag(objectList.get(num).toString());
        }
        num++;
        // FIS_CCY_CLA_PD  产品 货币市场基金
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            dimPdInfo.setFisCcyClaPd(objectList.get(num).toString());
        }
        num++;
        // FPD_TX_STATUS  产品 产品状态
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            dimPdInfo.setFpdTxStatus(objectList.get(num).toString());
        }
        num++;
        // FEXSIT_PERIOD  产品 产品期限
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            dimPdInfo.setFexsitPeriod(objectList.get(num).toString());
        }
        num++;
        // FCCY_CD  产品 币种代码
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            dimPdInfo.setFccyCd(objectList.get(num).toString());
        }
        num++;
        dimPdInfo.setOrderNum(orderNumInfo);
        listDimPdInfo.add(dimPdInfo);
        return num;
    }


    // 资讯的指标
    private int getDimInfoInfoList(List<Object> objectList, List<DimInfoInfo> listDimInfoInfo, int orderNumInfo, int num) {
        DimInfoInfo infoInfo = new DimInfoInfo();
        Object findxTpCode = objectList.get(0); // 指标类型编号
        infoInfo.setFindxTpCode(findxTpCode.toString());
        // FEXCH_CD 资讯 上市市场
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            infoInfo.setFexchCd(objectList.get(num).toString());
        }
        num++;
        // FSEC_CLA 资讯 证券分类
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            infoInfo.setFsecCla(objectList.get(num).toString());
        }
        num++;
        // FSEC_CLA_MAX_CLA 资讯 证券类型大类
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            infoInfo.setFsecClaMaxCla(objectList.get(num).toString());
        }
        num++;
        // FSEC_CLA_MIN_CLA  资讯 证券类型小类
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            infoInfo.setFsecClaMinCla(objectList.get(num).toString());
        }
        num++;
        // FSEC_TP  资讯 证券类别
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            infoInfo.setFsecTp(objectList.get(num).toString());
        }
        num++;
        // FIND_CLA  资讯 行业分类
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            infoInfo.setFindCla(objectList.get(num).toString());
        }
        num++;
        // FISSUER_NM  资讯 发行人名称
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            infoInfo.setFissuerNm(objectList.get(num).toString());
        }
        num++;
        // YHGSLX  央行公司类型
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            infoInfo.setFyhgslx(objectList.get(num).toString());
        }
        num++;
        // FDEBT_RATING_CONT  资讯 债项评级
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            infoInfo.setFdebtRatingCont(objectList.get(num).toString());
        }
        num++;
        // FORG_RATING_CONT  资讯 主体评级
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            infoInfo.setForgRatingCont(objectList.get(num).toString());
        }
        num++;
        // FDEBT_RATING_ORG  资讯 债项评级机构
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            infoInfo.setFdebtRatingOrg(objectList.get(num).toString());
        }
        num++;
        // FORG_RATING_ORG  资讯 主体评级机构
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            infoInfo.setForgRatingOrg(objectList.get(num).toString());
        }
        num++;
        // FORG_DEBT_RATING_ORG  资讯 债项主体评级优先主体
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            infoInfo.setForgDebtRatingOrg(objectList.get(num).toString());
        }
        num++;
        // FIS_INDEF_BOND  资讯 是否永续债
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            infoInfo.setFisIndefBond(objectList.get(num).toString());
        }
        num++;
        // FORG_AMT  资讯 发行人规模(机构规模)
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            infoInfo.setForgAmt(objectList.get(num).toString());
        }
        num++;
        // FBANK_CAPTL_SUPPLY_INST 资讯 银行资本补充工具分类
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            infoInfo.setFbankCaptlSupplyInst(objectList.get(num).toString());
        }
        num++;
        // FDOM_FGN_CD 资讯 境内境外
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            infoInfo.setFdomFgnCd(objectList.get(num).toString());
        }
        num++;
        // FCNTPTY_CENBK_CLA 资讯 对手方人行分类
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            infoInfo.setFcntptyCenbkCla(objectList.get(num).toString());
        }
        num++;
        infoInfo.setOrderNum(orderNumInfo);
        listDimInfoInfo.add(infoInfo);
        return num;
    }


    // 交易维度指标
    private int getDimTxInfoList(List<Object> objectList, List<DimTxInfo> listDimTxInfo, int orderNumInfo, int num) {
        DimTxInfo txInfo = new DimTxInfo();
        Object findxTpCode = objectList.get(0); // 指标类型编号
        txInfo.setFindxTpCode(findxTpCode.toString());
        // FINVEST_CLA_CD 交易 投资分类
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            txInfo.setFinvestClaCd(objectList.get(num).toString());
        }
        num++;
        // FEXCH_CD 交易 市场代码
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            txInfo.setFexchCd(objectList.get(num).toString());
        }
        num++;
        // FTX_ATTR_CD 交易 交易属性
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            txInfo.setFtxAttrCd(objectList.get(num).toString());
        }
        num++;
        // FTX_TP_CD  交易 交易类型
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(50).toString())) {
            txInfo.setFtxTpCd(objectList.get(num).toString());
        }
        num++;
        // FTX_MODE_CD  交易 交易方式
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            txInfo.setFtxModeCd(objectList.get(num).toString());
        }
        num++;
        // FBIZ_TP_CD  交易 业务类型
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            txInfo.setFbizTpCd(objectList.get(num).toString());
        }
        num++;
        // FSEC_VARIETIES_CD  交易 证券品种
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            txInfo.setFsecVarietiesCd(objectList.get(num).toString());
        }
        num++;
        // FSEC_VARIETIES_DTL_CD  交易 证券品种明细
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            txInfo.setFsecVarietiesDtlCd(objectList.get(num).toString());
        }
        num++;
        // FTX_CNTPTY_CD  交易 对手方代码
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            txInfo.setFtxCntptyCd(objectList.get(num).toString());
        }
        num++;
        // FIS_CONS_FLOAT  交易 是否受限流通
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            txInfo.setFisConsFloat(objectList.get(num).toString());
        }
        num++;
        txInfo.setOrderNum(orderNumInfo);
        listDimTxInfo.add(txInfo);
        return num;
    }

    // 非标维度指标
    private int getDimNoStInfoList(List<Object> objectList, List<DimNoStInfo> listDimNoStInfo, int orderNumInfo, int num) {
        DimNoStInfo noStInfo = new DimNoStInfo();
        Object findxTpCode = objectList.get(0); // 指标类型编号
        noStInfo.setFindxTpCode(findxTpCode.toString());
        // FCENBK_CLA 非标 人行分类
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            noStInfo.setFcenbkCla(objectList.get(num).toString());
        }
        num++;
        // FIND_CLA 非标 行业分类
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            noStInfo.setFindCla(objectList.get(num).toString());
        }
        num++;
        // FBAS_ORG_AMT 非标 企业规模(基础资产出让机构规模)
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(59).toString())) {
            noStInfo.setFbasOrgAmt(objectList.get(num).toString());
        }
        num++;
        // FBAS_ORG_REGIST_REGI  非标 地区(基础资产出让机构注册地区)
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            noStInfo.setFbasOrgRegistRegi(objectList.get(num).toString());
        }
        num++;
        // FBAS_TP  非标 基础资产类型
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            noStInfo.setFbasTp(objectList.get(num).toString());
        }
        num++;
        noStInfo.setOrderNum(orderNumInfo);
        listDimNoStInfo.add(noStInfo);
        return num;
    }

    // TA维度指标
    private int getDimTaInfoList(List<Object> objectList, List<DimTaInfo> listDimTaInfo, int orderNumInfo, int num) {
        DimTaInfo taInfo = new DimTaInfo();
        Object findxTpCode = objectList.get(0); // 指标类型编号
        taInfo.setFindxTpCode(findxTpCode.toString());
        // FCUST_CENBK_TP_CD TA 客户央行类型
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            taInfo.setFcustCenbkTpCd(objectList.get(num).toString());
        }
        num++;
        // FCUST_CENBK_SUB_TP_CD TA 子客户类型(客户央行子类型代码)
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            taInfo.setFcustCenbkSubTpCd(objectList.get(num).toString());
        }
        num++;
        // FSETTLE_CCY TA 原币币种
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            taInfo.setFsettleCcy(objectList.get(num).toString());
        }
        num++;
        // FRAISE_BAL_CD  TA 募集余额
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            taInfo.setFraiseBalCd(objectList.get(num).toString());
        }
        num++;
        // FREGION  TA 地区
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            taInfo.setFregion(objectList.get(num).toString());
        }
        num++;
        // FTX_TP_CD   TA 业务类型
        if (StringUtils.isNotNull(objectList.get(num)) && StringUtils.isNotEmpty(objectList.get(num).toString())) {
            taInfo.setFtxTpCd(objectList.get(num).toString());
        }
        num++;
        taInfo.setOrderNum(orderNumInfo);
        listDimTaInfo.add(taInfo);
        return num;
    }

}
